import { getData, relatedBatch } from '@vimi/utils-api'
import { SERVICE_NAME } from '@/credit/plugins/constant'

const masterTableName = 'update_record'
const slaveTableName = 'update_record_detail'

export const getHistory = (params, order) =>
  getData(SERVICE_NAME, masterTableName, params, order).then(
    res => res?.data ?? { data: [], totalCount: 0 }
  )

export const addHistory = (masterData, slaveData) =>
  relatedBatch(SERVICE_NAME, {
    masterTableInfo: JSON.stringify(masterData),
    masterTableName,
    slaveTableInfo: JSON.stringify(slaveData),
    slaveTableName,
  })
